﻿@{
    ViewBag.Title = "ConfigPage";
    Layout = null;
}

<html>
<head>
    <title>大转盘后台配置页</title>
    <style type="text/css">
        #dtTable td {
            text-align: center;
            border-bottom: solid 1px solid;
        }
    </style>
    <script src="~/js/jquery.js"></script>
</head>
<body style="background-color: #0ff;">
    <div style="background-color: #21e2cb; border: 1px solid #00ff21; width: 80%; margin: auto;">
        <input type="button" value="@(ViewBag.openStatu == 0 ? "开启活动" : "关闭活动")" id="btnChangeActStatu" statu="@ViewBag.openStatu" />

        <input type="button" value="清空数据" id="btnClearData" />

        奖品剩余数量：
        <input type="text" id="txtsygs" value="@ViewBag.sygs"/>
        <input type="button" id="btnSetSyCount" value="设置剩余个数" />

        <h2>中奖名单</h2>
        <table style="width: 100%" id="dtTable">
            <tr>
                <th>昵称</th>
                <th>openId</th>
                <th>头像</th>
            </tr>
            <tbody id="tbody1"></tbody>
        </table>
    </div>
</body>
</html>

<script type="text/javascript">
    $(function () {
        getZJMd();
        $("#btnClearData").click(function () {
            if (confirm("确定要清除吗？")) {
                $.ajax({
                    url: "@Url.Action("ClearData", "ActZhounianQing")",
                    data: {},
                    type: "post",
                    success: function (data) {
                        if (data == "1") {
                            alert("清除成功！");
                        } else {
                            alert(data);
                        }
                    }

                });
            }

        });


        $("#btnSetSyCount").click(function () {
            if (confirm("确定要操作吗？")) {
                $.ajax({
                    url: "@Url.Action("SetSyCount", "ActZhounianQing")",
                    data: { sycount: $("#txtsygs").val() },
                    type: "post",
                    success: function (data) {
                        if (data == "1") {
                            alert("设置成功")
                        } else {
                            alert("设置失败！");
                        }
                    }

                });
            }
        });

        $("#btnChangeActStatu").click(function () {
            if (confirm("确定要操作吗？")) {
                $.ajax({
                    url: "@Url.Action("CloseOrOpenAct", "ActZhounianQing")",
                    data: { statu:$(this).attr("statu")=="1"?"0":"1"  },
                    type: "post",
                    success: function (data) {
                        if (data == "1") {
                            var f = $(this).attr("statu") == "1";
                            $(this).attr("statu", f ? "0" : "1");
                            $(this).attr("value", f ? "开启活动" : "关闭活动");
                            alert("设置成功")
                        } else {
                            alert("设置失败！");
                        }
                    }

                });
            }
        });
      

    });
    //中奖名单
    function getZJMd() {
        $.ajax({
            url: "@Url.Action("GetZJMDList", "ActZhounianQing")",
            data: {},
            type: "post",
            dataType: 'json',
            success: function (data) {
                var $tbody = $("#tbody1");
                $tbody.html("");
                var htmlStr = "";
                for (var i = 0; i < data.length; i++) {
                    htmlStr += "<tr><td>" + data[i].nickName + "</td><td>" + data[i].openid + "</td><td><img width='40' heght='40' src='" + data[i].head_Img + "'</td></tr>";
                }
                $tbody.html(htmlStr);
            }
        });
    }

    function changeStatu() {
        //$.ajax();
    }



</script>
